<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增人口学')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body>
    <div class="main-content">
        <form class="form-horizontal m" id="form-demography-add">
        	<input id="identityCardImg" name="identityCardImg" type="hidden">
        	<h4 class="form-header h4">人口学信息</h4>
        	<div class="row">
        		<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">姓名：</label>
                        <div class="col-sm-8">
                        	<input name="demographyName" class="form-control" maxlength="30" required  isName type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">性别：</label>
                        <div class="col-sm-8">
                            <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
				                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
				            </select>
                        </div>
                    </div>
                </div>
        	</div>
        	<div class="row">
        		<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">生日：</label>
                        <div class="col-sm-8">
                        	<div class="input-group date">
	                        	<input name="birthday" class="form-control" placeholder="yyyy-MM-dd" type="text" readonly required>
	                        	<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        	</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">民族：</label>
                        <div class="col-sm-8">
		                    <select name="nation" class="form-control m-b" th:with="type=${@dict.getType('sys_nation')}">
				                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
				            </select>
                        </div>
                    </div>
                </div>
        	</div>
        	<div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">身份证：</label>
                        <div class="col-sm-10">
                            <input name="identityCard" maxlength="20" class="form-control" isIdentity="true" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">住址：</label>
                        <div class="col-xs-10">
                            <input name="address" maxlength="100" class="form-control" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">照片：</label>
                        <div class="col-xs-10">
                            <div class="file-loading">
					            <input id="file" name="file" type="file">
					        </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">
        var prefix = ctx + "kt/demography";
        var uploadFix = ctx+"common/upload";
        $("#form-demography-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-demography-add').serialize());
            }
        }

        $("input[name='birthday']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
        $(document).ready(function () {
            $("#file").fileinput({
                'uploadUrl': uploadFix,
                initialPreviewFileType: 'image',
                showUpload: false,
                uploadAsync: true,
                dropZoneEnabled: false,
                maxFileCount: 1,
                overwriteInitial: true,
                allowedFileTypes: 'image',
                allowedFileExtensions:  ['jpg', 'png', 'gif']
            });
            
            $("#file").on("fileuploaded", function(event, data) {
                var response = data.response
                $("#identityCardImg").val(response.fileName);
            }).on('filebatchselected', function (event, files) {
            	  $(this).fileinput("upload");
            });
            
        });
        
       
    </script>
</body>
</html>